home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 186 / gfatip16 / fsel_inp.lst next >
File List  |  1988-05-15  |  5KB  |  159 lines

  1. ' GFATIP16 .LST Library Source Code is Copyright 1988 Marathon Computer Press
  2. ' Procedure: Fsel_input
  3. ' Dependencies : Get_drive, Strip_file_path, Getrez
  4. '
  5. '  This procedure requires that you supply either a file name or a legal
  6. ' file extension.  IE.. either ( "*.BAS", or "MYPROG.BAS" ).  This value must
  7. ' be declared in the string variable Supply$.  Flag% is set to one if you want
  8. ' the Fsel_title$ to appear above the standard Fileselector box.  This works
  9. ' ONLY with the Standard Fileselector, or the UIS.  Most of the Public Domain
  10. ' fileselectors we've seen are too large and will obscure the title placard.
  11. ' However:
  12. ' The rest of the Fsel_input procedure code will work with ANY fileselector!
  13. ' It's up to you if you want to use the placard above the box.  If you
  14. ' do, remember to set Flag% to 1
  15. '
  16. '
  17. '
  18. '   Example:
  19. '               Supply$="\*.BAS"
  20. '               @Fsel_input(Supply$,Fsel_title$,Flag%)
  21. '
  22. '
  23. ' Returned values:
  24. '                      Fsel$ = The chosen file name
  25. '                 Full_path$ = Full selected path
  26. '              Currentdrive$ = Current drive
  27. '                      Path$ = File path only, minus the chosen file
  28. '
  29. ' Considerations:
  30. '  This procedure allows for the "Sticky Setting" of file paths.  However, if
  31. ' you desire to return to the original drive, you should include the following
  32. ' code to accomplish a return to a "Home drive".
  33. '
  34. '               @Get_drive
  35. '               Old_drive%=Gfadrive%
  36. '               Oldpath$=Dir$(0)
  37. '               If Oldpath$=""
  38. '                 Oldpath$="\"
  39. '               Endif
  40. '
  41. '             ** Next we do our call to Fsel_input **
  42. '               Supply$="\*.BAS"
  43. '               @Fsel_input(Supply$)
  44. '
  45. '             ** Next you do what you want with the chosen
  46. '                file and drive (if changed)
  47. '              ' Write the file or read the file
  48. '
  49. '             ** Now to return to our old settings **
  50. '               Chdrive Old_drive%
  51. '               Chdir Oldpath$
  52. '
  53. '  We may also pass in a Title for the Fileselect Box if desired.  It is passed
  54. ' to the procedure in the text string Fsel_title$.  In order to use the option
  55. ' you must also turn on the usage flag.  Do not try to center the text, this
  56. ' will be done for you.  Also, you are limited to 35 characters in length.  If
  57. ' the passed Fsel_title$ is longer, it will be truncated.
  58. '
  59. '
  60. '                Supply$="\*.BAS"
  61. '                Fsel_title$=" Write a File "
  62. '                Flag%=1 ! 1=On, 0=Off
  63. '                @Fsel_input(Supply$,Fsel_title$,Flag%)
  64. '
  65. '
  66. '
  67. '
  68. Procedure Fsel_input(Supply$,Fsel_title$,Flag%)
  69.   '
  70.   @Getrez
  71.   Clr Nowhere$,Fsel$
  72.   @Get_drive
  73.   If Left$(Supply$,1)<>"\"
  74.     Supply$="\"+Supply$
  75.   Endif
  76.   '
  77.   '    ** The next section is optional for the Fsel_title **
  78.   ' You can remove the section without damaging the rest of the
  79.   ' routine.
  80.   '
  81.   ' Get Resolution information and draw the box accordingly.  We only support
  82.   ' medium and high resolution, so if the routine is used with low resolution
  83.   ' you will have to modify it a bit.
  84.   '
  85.   If Flag%=1 ! Check to see if it's active   ** Med or High Rez Only **
  86.     If Rez%=2
  87.       Get 175,30,465,53,Tempuse$ ! Get the background and save it.
  88.       Graphmode 1
  89.       Deftext 1,0,0,13
  90.       Defline 1,1
  91.       Deffill 0,2,8
  92.       Pbox 175,30,465,53
  93.       Box 175,30,465,53
  94.       ' Now for some centering
  95.       '
  96.       Temp%=Len(Fsel_title$)
  97.       Temp2%=35-Temp%
  98.       Temp$=Space$(Temp2%/2)
  99.       Clr Temp%,Temp2%
  100.       Fsel_title$=Temp$+Fsel_title$
  101.       Text 180,50,Fsel_title$
  102.       '
  103.     Else ! Medium Resolution
  104.       '
  105.       Get 170,10,465,23,Tempuse$ ! Get the background and save it.
  106.       Graphmode 1
  107.       Deftext 1,0,0,6
  108.       Defline 1,1
  109.       Deffill 0,2,8
  110.       Pbox 170,10,465,23
  111.       Box 170,10,465,23
  112.       ' Now for some centering
  113.       '
  114.       Temp%=Len(Fsel_title$)
  115.       Temp2%=35-Temp%
  116.       Temp$=Space$(Temp2%/2)
  117.       Clr Temp%,Temp2%
  118.       Fsel_title$=Temp$+Fsel_title$
  119.       Text 175,20,Fsel_title$
  120.     Endif
  121.   Endif
  122.   '
  123.   '
  124.   '
  125.   '
  126.   Repeat
  127.     Fileselect Currentdrive$+":"+Dir$(0)+Supply$,File$,Nowhere$
  128.     Exit If Nowhere$=""
  129.   Until Len(Nowhere$)<>1
  130.   If Nowhere$<>"" Then
  131.     Currentpath$=Dir$(0)
  132.     If Currentpath$=""
  133.       Currentpath$="\"
  134.     Endif
  135.     @Strip_file_path
  136.     @Get_drive
  137.     If Newdrive%<>0
  138.       Chdrive Newdrive%
  139.     Endif
  140.     Chdir Path$
  141.   Endif
  142.   Full_path$=Nowhere$
  143.   '
  144.   '
  145.   If Flag%=1
  146.     ' If you are using Fsel_title$ do not remove this
  147.     ' However, if you have not removed Get X,Y,X2,Y2,Tempuse$
  148.     ' You program WILL crash if you leave this in.
  149.     If Rez%=2
  150.       Put 175,30,Tempuse$,3 ! Overwrite the title placard
  151.     Else
  152.       Put 170,10,Tempuse$,3
  153.     Endif
  154.     Clr Tempuse$
  155.   Endif
  156.   '
  157.   '
  158. Return
  159.